mirror of
https://github.com/tateisu/SubwayTooter
synced 2025-01-29 18:19:22 +01:00
添付メディアを開くときに優先的にChrome Custom Tabsを利用する。返信時に自動入力されるメンションに自分のacctが余計に含まれる場合があった。
This commit is contained in:
parent
a6fe6c0b96
commit
b9ef1690c1
@ -9,8 +9,8 @@ android {
|
||||
applicationId "jp.juggler.subwaytooter"
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 25
|
||||
versionCode 29
|
||||
versionName "0.2.9"
|
||||
versionCode 30
|
||||
versionName "0.3.0"
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ package jp.juggler.subwaytooter;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.ComponentName;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
@ -892,14 +893,24 @@ public class ActMain extends AppCompatActivity
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// ビルダーを使って表示方法を指定する
|
||||
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
|
||||
builder.setToolbarColor( Styler.getAttributeColor( this, R.attr.colorPrimary ) ).setShowTitle( true );
|
||||
|
||||
// CustomTabsでURLをひらくIntentを発行
|
||||
CustomTabsIntent customTabsIntent = builder.build();
|
||||
customTabsIntent.launchUrl( this, Uri.parse( url ) );
|
||||
|
||||
try{
|
||||
// 初回はChrome指定で試す
|
||||
|
||||
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
|
||||
builder.setToolbarColor( Styler.getAttributeColor( this, R.attr.colorPrimary ) ).setShowTitle( true );
|
||||
CustomTabsIntent customTabsIntent = builder.build();
|
||||
customTabsIntent.intent.setComponent( new ComponentName("com.android.chrome","com.google.android.apps.chrome.Main" ) );
|
||||
customTabsIntent.launchUrl( this, Uri.parse( url ) );
|
||||
}catch(Throwable ex2){
|
||||
log.e( ex2, "openChromeTab: missing chrome. retry to other application.");
|
||||
|
||||
// chromeがないなら ResolverActivity でアプリを選択させる
|
||||
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
|
||||
builder.setToolbarColor( Styler.getAttributeColor( this, R.attr.colorPrimary ) ).setShowTitle( true );
|
||||
CustomTabsIntent customTabsIntent = builder.build();
|
||||
customTabsIntent.launchUrl( this, Uri.parse( url ) );
|
||||
}
|
||||
|
||||
}catch( Throwable ex ){
|
||||
// ex.printStackTrace();
|
||||
|
@ -232,9 +232,8 @@ public class ActPost extends AppCompatActivity implements View.OnClickListener {
|
||||
etContentWarning.setText( reply_status.spoiler_text );
|
||||
}
|
||||
|
||||
// mention を自動設定する
|
||||
ArrayList< String > mention_list = new ArrayList<>();
|
||||
mention_list.add( "@" + account.getFullAcct( reply_status.account ) );
|
||||
// 元レスにあった mention
|
||||
if( reply_status.mentions != null ){
|
||||
for( TootMention mention : reply_status.mentions ){
|
||||
|
||||
@ -246,6 +245,18 @@ public class ActPost extends AppCompatActivity implements View.OnClickListener {
|
||||
}
|
||||
}
|
||||
}
|
||||
// 今回メンションを追加する?
|
||||
{
|
||||
sv = account.getFullAcct( reply_status.account );
|
||||
//noinspection StatementWithEmptyBody
|
||||
if( mention_list.contains( "@" + sv ) ){
|
||||
// 既に含まれている
|
||||
}else if( ! account.isMe( reply_status.account ) || mention_list.isEmpty() ){
|
||||
// 自分ではない、もしくは、メンションが空
|
||||
mention_list.add( "@" + sv );
|
||||
}
|
||||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for( String acct : mention_list ){
|
||||
if( sb.length() > 0 ) sb.append( ' ' );
|
||||
@ -424,7 +435,7 @@ public class ActPost extends AppCompatActivity implements View.OnClickListener {
|
||||
@Override
|
||||
public void onTextChanged( CharSequence s, int start, int before, int count ){
|
||||
handler.removeCallbacks( proc_text_changed );
|
||||
handler.postDelayed( proc_text_changed, (popup!= null && popup.isShowing() ? 100L : 1000L ));
|
||||
handler.postDelayed( proc_text_changed, ( popup != null && popup.isShowing() ? 100L : 1000L ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -509,7 +520,7 @@ public class ActPost extends AppCompatActivity implements View.OnClickListener {
|
||||
closeAcctPopup();
|
||||
}else{
|
||||
if( popup == null || ! popup.isShowing() ){
|
||||
popup = new PopupAutoCompleteAcct( ActPost.this, etContent ,formRoot);
|
||||
popup = new PopupAutoCompleteAcct( ActPost.this, etContent, formRoot );
|
||||
}
|
||||
popup.setList( acct_list, start, end );
|
||||
}
|
||||
@ -815,7 +826,7 @@ public class ActPost extends AppCompatActivity implements View.OnClickListener {
|
||||
public String getDocumentName( Uri uri ){
|
||||
|
||||
Cursor cursor = getContentResolver().query( uri, null, null, null, null, null );
|
||||
if( cursor != null){
|
||||
if( cursor != null ){
|
||||
try{
|
||||
if( cursor.moveToFirst() ){
|
||||
return cursor.getString( cursor.getColumnIndex( OpenableColumns.DISPLAY_NAME ) );
|
||||
@ -945,6 +956,7 @@ public class ActPost extends AppCompatActivity implements View.OnClickListener {
|
||||
@Override public boolean isApiCancelled(){
|
||||
return isCancelled();
|
||||
}
|
||||
|
||||
@Override public void publishApiProgress( final String s ){
|
||||
Utils.runOnMainThread( new Runnable() {
|
||||
@Override public void run(){
|
||||
@ -963,8 +975,7 @@ public class ActPost extends AppCompatActivity implements View.OnClickListener {
|
||||
TootApiClient.MEDIA_TYPE_FORM_URL_ENCODED
|
||||
, post_content
|
||||
) )
|
||||
.header( "Idempotency-Key" ,digest)
|
||||
;
|
||||
.header( "Idempotency-Key", digest );
|
||||
|
||||
TootApiResult result = client.request( "/api/v1/statuses", request_builder );
|
||||
if( result.object != null ){
|
||||
@ -982,6 +993,7 @@ public class ActPost extends AppCompatActivity implements View.OnClickListener {
|
||||
@Override
|
||||
protected void onPostExecute( TootApiResult result ){
|
||||
progress.dismiss();
|
||||
//noinspection StatementWithEmptyBody
|
||||
if( result == null ){
|
||||
// cancelled.
|
||||
}else if( status != null ){
|
||||
|
Loading…
x
Reference in New Issue
Block a user