session-android/src/org/thoughtcrime/securesms/LogSubmitActivity.java

81 lines
2.2 KiB
Java
Raw Normal View History

2014-02-25 19:53:12 -08:00
package org.thoughtcrime.securesms;
import android.content.ActivityNotFoundException;
import android.content.Intent;
2014-02-25 19:53:12 -08:00
import android.os.Bundle;
import androidx.fragment.app.FragmentTransaction;
2014-06-28 20:40:57 -07:00
import android.view.MenuItem;
2014-02-25 19:53:12 -08:00
import android.widget.Toast;
2019-07-24 12:30:23 +10:00
import org.thoughtcrime.securesms.logging.Log;
2018-07-30 16:13:37 -04:00
import org.thoughtcrime.securesms.logsubmit.SubmitLogFragment;
import org.thoughtcrime.securesms.util.DynamicTheme;
2014-02-25 19:53:12 -08:00
2019-07-24 12:30:23 +10:00
import network.loki.messenger.R;
2014-02-25 19:53:12 -08:00
/**
* Activity for submitting logcat logs to a pastebin service.
*/
public class LogSubmitActivity extends BaseActionBarActivity implements SubmitLogFragment.OnLogSubmittedListener {
2014-02-25 19:53:12 -08:00
private static final String TAG = LogSubmitActivity.class.getSimpleName();
private DynamicTheme dynamicTheme = new DynamicTheme();
2014-02-25 19:53:12 -08:00
@Override
protected void onCreate(Bundle icicle) {
dynamicTheme.onCreate(this);
2014-02-25 19:53:12 -08:00
super.onCreate(icicle);
setContentView(R.layout.log_submit_activity);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
SubmitLogFragment fragment = SubmitLogFragment.newInstance();
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.replace(R.id.fragment_container, fragment);
transaction.commit();
2014-02-25 19:53:12 -08:00
}
@Override
protected void onResume() {
dynamicTheme.onResume(this);
2014-02-25 19:53:12 -08:00
super.onResume();
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
super.onOptionsItemSelected(item);
switch (item.getItemId()) {
case android.R.id.home:
finish();
return true;
}
return false;
}
@Override
public void onSuccess() {
Toast.makeText(getApplicationContext(), R.string.log_submit_activity__thanks, Toast.LENGTH_LONG).show();
finish();
2014-02-25 19:53:12 -08:00
}
@Override
public void onFailure() {
Toast.makeText(getApplicationContext(), R.string.log_submit_activity__log_fetch_failed, Toast.LENGTH_LONG).show();
finish();
2014-02-25 19:53:12 -08:00
}
@Override
public void onCancel() {
finish();
2014-02-25 19:53:12 -08:00
}
@Override
public void startActivity(Intent intent) {
try {
super.startActivity(intent);
} catch (ActivityNotFoundException e) {
Log.w(TAG, e);
Toast.makeText(this, R.string.log_submit_activity__no_browser_installed, Toast.LENGTH_LONG).show();
}
}
2014-02-25 19:53:12 -08:00
}