他アプリから共有で投稿した後に画面を回転すると再度投稿画面を開いてしまう問題の修正。アプリ設定にクライアント名を追加。

This commit is contained in:
tateisu 2017-07-11 07:39:45 +09:00
parent 7b5da59761
commit e5626c5539
11 changed files with 48 additions and 15 deletions

View File

@ -400,7 +400,7 @@ public class ActAccountSetting extends AppCompatActivity
} ); } );
api_client.setAccount( account ); api_client.setAccount( account );
return api_client.authorize1(); return api_client.authorize1( Pref.pref(ActAccountSetting.this).getString(Pref.KEY_CLIENT_NAME,""));
} }
@Override protected void onPostExecute( TootApiResult result ){ @Override protected void onPostExecute( TootApiResult result ){

View File

@ -125,6 +125,8 @@ public class ActAppSetting extends AppCompatActivity
EditText etColumnWidth; EditText etColumnWidth;
EditText etMediaThumbHeight; EditText etMediaThumbHeight;
EditText etClientName;
TextView tvTimelineFontUrl; TextView tvTimelineFontUrl;
String timeline_font; String timeline_font;
@ -274,12 +276,16 @@ public class ActAppSetting extends AppCompatActivity
vIndicator = findViewById( R.id.vIndicator ); vIndicator = findViewById( R.id.vIndicator );
etColumnWidth = (EditText) findViewById( R.id.etColumnWidth ); etColumnWidth = (EditText) findViewById( R.id.etColumnWidth );
etColumnWidth.addTextChangedListener( this );
etMediaThumbHeight = (EditText) findViewById( R.id.etMediaThumbHeight ); etMediaThumbHeight = (EditText) findViewById( R.id.etMediaThumbHeight );
etMediaThumbHeight.addTextChangedListener( this );
etClientName = (EditText) findViewById( R.id.etClientName );
etClientName.addTextChangedListener( this );
tvTimelineFontUrl = (TextView) findViewById( R.id.tvTimelineFontUrl ); tvTimelineFontUrl = (TextView) findViewById( R.id.tvTimelineFontUrl );
etColumnWidth.addTextChangedListener( this );
etMediaThumbHeight.addTextChangedListener( this );
} }
boolean load_busy; boolean load_busy;
@ -325,7 +331,7 @@ public class ActAppSetting extends AppCompatActivity
etColumnWidth.setText( pref.getString( Pref.KEY_COLUMN_WIDTH, "" ) ); etColumnWidth.setText( pref.getString( Pref.KEY_COLUMN_WIDTH, "" ) );
etMediaThumbHeight.setText( pref.getString( Pref.KEY_MEDIA_THUMB_HEIGHT, "" ) ); etMediaThumbHeight.setText( pref.getString( Pref.KEY_MEDIA_THUMB_HEIGHT, "" ) );
etClientName.setText( pref.getString( Pref.KEY_CLIENT_NAME, "" ) );
timeline_font = pref.getString( Pref.KEY_TIMELINE_FONT, "" ); timeline_font = pref.getString( Pref.KEY_TIMELINE_FONT, "" );
load_busy = false; load_busy = false;
@ -373,7 +379,8 @@ public class ActAppSetting extends AppCompatActivity
.putString( Pref.KEY_TIMELINE_FONT, timeline_font ) .putString( Pref.KEY_TIMELINE_FONT, timeline_font )
.putString( Pref.KEY_COLUMN_WIDTH, etColumnWidth.getText().toString().trim() ) .putString( Pref.KEY_COLUMN_WIDTH, etColumnWidth.getText().toString().trim() )
.putString( Pref.KEY_MEDIA_THUMB_HEIGHT, etMediaThumbHeight.getText().toString().trim() ) .putString( Pref.KEY_MEDIA_THUMB_HEIGHT, etMediaThumbHeight.getText().toString().trim() )
.putString( Pref.KEY_CLIENT_NAME, etClientName.getText().toString().trim() )
.apply(); .apply();
} }

View File

@ -252,6 +252,7 @@ public class ActMain extends AppCompatActivity
, getString( R.string.account_picker_toot ) , getString( R.string.account_picker_toot )
, new AccountPicker.AccountPickerCallback() { , new AccountPicker.AccountPickerCallback() {
@Override public void onAccountPicked( @NonNull SavedAccount ai ){ @Override public void onAccountPicked( @NonNull SavedAccount ai ){
sent_intent2 = null;
ActPost.open( ActMain.this, REQUEST_CODE_POST, ai.db_id, intent ); ActPost.open( ActMain.this, REQUEST_CODE_POST, ai.db_id, intent );
} }
} }
@ -923,7 +924,7 @@ public class ActMain extends AppCompatActivity
if( bPseudoAccount ){ if( bPseudoAccount ){
return api_client.checkInstance(); return api_client.checkInstance();
}else{ }else{
return api_client.authorize1(); return api_client.authorize1( Pref.pref(ActMain.this).getString(Pref.KEY_CLIENT_NAME,""));
} }
} }

View File

@ -327,6 +327,7 @@ public class AppDataExporter {
case Pref.KEY_STREAM_LISTENER_CONFIG_URL: case Pref.KEY_STREAM_LISTENER_CONFIG_URL:
case Pref.KEY_STREAM_LISTENER_SECRET: case Pref.KEY_STREAM_LISTENER_SECRET:
case Pref.KEY_STREAM_LISTENER_CONFIG_DATA: case Pref.KEY_STREAM_LISTENER_CONFIG_DATA:
case Pref.KEY_CLIENT_NAME:
String sv = reader.nextString(); String sv = reader.nextString();
e.putString( k, sv ); e.putString( k, sv );
break; break;

View File

@ -6,7 +6,6 @@ import android.preference.PreferenceManager;
public class Pref { public class Pref {
static SharedPreferences pref( Context context ){ static SharedPreferences pref( Context context ){
return PreferenceManager.getDefaultSharedPreferences( context ); return PreferenceManager.getDefaultSharedPreferences( context );
} }
@ -58,6 +57,9 @@ public class Pref {
static final String KEY_PRIOR_CHROME = "prior_chrome"; static final String KEY_PRIOR_CHROME = "prior_chrome";
static final String KEY_POST_BUTTON_BAR_AT_TOP = "post_button_bar_at_top"; static final String KEY_POST_BUTTON_BAR_AT_TOP = "post_button_bar_at_top";
static final String KEY_CLIENT_NAME = "client_name";
// 項目を追加したらAppDataExporter#importPref のswitch文も更新すること // 項目を追加したらAppDataExporter#importPref のswitch文も更新すること
} }

View File

@ -235,7 +235,7 @@ public class TootApiClient {
} }
} }
public @Nullable TootApiResult authorize1(){ public @Nullable TootApiResult authorize1(String client_name){
JSONObject client_info; JSONObject client_info;
@ -248,7 +248,9 @@ public class TootApiClient {
Response response; Response response;
try{ try{
String client_name = "SubwayTooter"; // + UUID.randomUUID().toString(); if( TextUtils.isEmpty( client_name )){
client_name = "SubwayTooter";
}
Request request = new Request.Builder() Request request = new Request.Builder()
.url( "https://" + instance + "/api/v1/apps" ) .url( "https://" + instance + "/api/v1/apps" )

View File

@ -73,7 +73,7 @@ public class AccountPicker {
, String message , String message
, @NonNull final ArrayList< SavedAccount > account_list , @NonNull final ArrayList< SavedAccount > account_list
, @NonNull final AccountPickerCallback callback , @NonNull final AccountPickerCallback callback
, @Nullable final DialogInterface.OnDismissListener dissmiss_callback , @Nullable final DialogInterface.OnDismissListener dismiss_callback
){ ){
if( account_list.isEmpty() ){ if( account_list.isEmpty() ){
Utils.showToast( activity, false, R.string.account_empty ); Utils.showToast( activity, false, R.string.account_empty );
@ -110,8 +110,8 @@ public class AccountPicker {
final Dialog dialog = new Dialog( activity ); final Dialog dialog = new Dialog( activity );
final AtomicBoolean isDialogClosed = new AtomicBoolean( false ); final AtomicBoolean isDialogClosed = new AtomicBoolean( false );
if( dissmiss_callback != null ){ if( dismiss_callback != null ){
dialog.setOnDismissListener( dissmiss_callback ); dialog.setOnDismissListener( dismiss_callback );
} }
dialog.setContentView( viewRoot ); dialog.setContentView( viewRoot );
@ -168,8 +168,8 @@ public class AccountPicker {
b.setOnClickListener( new View.OnClickListener() { b.setOnClickListener( new View.OnClickListener() {
@Override public void onClick( View v ){ @Override public void onClick( View v ){
isDialogClosed.set(true); isDialogClosed.set(true);
dialog.dismiss();
callback.onAccountPicked( _a ); callback.onAccountPicked( _a );
dialog.dismiss();
} }
} ); } );
llAccounts.addView( b ); llAccounts.addView( b );

View File

@ -207,6 +207,23 @@
<View style="@style/setting_divider"/> <View style="@style/setting_divider"/>
<TextView
style="@style/setting_row_label"
android:text="@string/client_name"
android:labelFor="@+id/etClientName"
/>
<LinearLayout style="@style/setting_row_form">
<EditText
android:id="@+id/etClientName"
style="@style/setting_horizontal_stretch"
android:inputType="text"
/>
</LinearLayout>
<View style="@style/setting_divider"/>
<!-- =============================================== --> <!-- =============================================== -->

View File

@ -365,8 +365,9 @@
<string name="text_to_speech_initialize_failed">TextToSpeech initializing failed. status=%1$s</string> <string name="text_to_speech_initialize_failed">TextToSpeech initializing failed. status=%1$s</string>
<string name="text_to_speech_shutdown">TextToSpeech shutdown…</string> <string name="text_to_speech_shutdown">TextToSpeech shutdown…</string>
<string name="show_post_button_bar_top">Show buttons bar at the top of posting screen</string> <string name="show_post_button_bar_top">Show buttons bar at the top of posting screen</string>
<string name="client_name">Client name (access token update required)</string>
<!--<string name="abc_action_bar_home_description">Revenir à l\'accueil</string>--> <!--<string name="abc_action_bar_home_description">Revenir à l\'accueil</string>-->
<!--<string name="abc_action_bar_home_description_format">%1$s, %2$s</string>--> <!--<string name="abc_action_bar_home_description_format">%1$s, %2$s</string>-->
<!--<string name="abc_action_bar_home_subtitle_description_format">%1$s, %2$s, %3$s</string>--> <!--<string name="abc_action_bar_home_subtitle_description_format">%1$s, %2$s, %3$s</string>-->
<!--<string name="abc_action_bar_up_description">Revenir en haut de la page</string>--> <!--<string name="abc_action_bar_up_description">Revenir en haut de la page</string>-->

View File

@ -652,5 +652,6 @@
<string name="text_to_speech_initialize_failed">TextToSpeechの初期化に失敗。status=%1$s</string> <string name="text_to_speech_initialize_failed">TextToSpeechの初期化に失敗。status=%1$s</string>
<string name="text_to_speech_shutdown">TextToSpeechの後処理…</string> <string name="text_to_speech_shutdown">TextToSpeechの後処理…</string>
<string name="show_post_button_bar_top">投稿画面のボタンバーを上端に表示</string> <string name="show_post_button_bar_top">投稿画面のボタンバーを上端に表示</string>
<string name="client_name">クライアント名(アクセストークンの更新が必要)</string>
</resources> </resources>

View File

@ -360,4 +360,5 @@
<string name="text_to_speech_initialize_failed">TextToSpeech initializing failed. status=%1$s</string> <string name="text_to_speech_initialize_failed">TextToSpeech initializing failed. status=%1$s</string>
<string name="text_to_speech_shutdown">TextToSpeech shutdown…</string> <string name="text_to_speech_shutdown">TextToSpeech shutdown…</string>
<string name="show_post_button_bar_top">Show buttons bar at the top of posting screen</string> <string name="show_post_button_bar_top">Show buttons bar at the top of posting screen</string>
<string name="client_name">Client name (access token update required)</string>
</resources> </resources>