Made editable area take up the entire fragment and hid tabs in landscape mode
This commit is contained in:
parent
85b72b757c
commit
4064ca5163
2 changed files with 18 additions and 15 deletions
|
@ -12,6 +12,7 @@ import android.content.res.Configuration;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
import android.support.annotation.VisibleForTesting;
|
||||||
import android.support.design.widget.TabLayout;
|
import android.support.design.widget.TabLayout;
|
||||||
import android.support.v4.app.ActivityCompat;
|
import android.support.v4.app.ActivityCompat;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
|
@ -31,6 +32,7 @@ import android.util.Log;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.SearchEvent;
|
import android.view.SearchEvent;
|
||||||
|
import android.view.View;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.webkit.MimeTypeMap;
|
import android.webkit.MimeTypeMap;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
|
@ -58,7 +60,6 @@ public class MainActivity extends AppCompatActivity
|
||||||
|
|
||||||
private static final String TAG = MainActivity.class.getSimpleName();
|
private static final String TAG = MainActivity.class.getSimpleName();
|
||||||
private static String fileName;
|
private static String fileName;
|
||||||
public static FileUtils mFileUtils;
|
|
||||||
|
|
||||||
public static String getTempFileName() {
|
public static String getTempFileName() {
|
||||||
return "tmp_" + getFileName();
|
return "tmp_" + getFileName();
|
||||||
|
@ -94,7 +95,6 @@ public class MainActivity extends AppCompatActivity
|
||||||
new EditPagerAdapter(getSupportFragmentManager(), MainActivity.this)
|
new EditPagerAdapter(getSupportFragmentManager(), MainActivity.this)
|
||||||
);
|
);
|
||||||
mFilesDir = getFilesDir();
|
mFilesDir = getFilesDir();
|
||||||
checkDirectories();
|
|
||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
if (intent != null && !intent.getAction().equals(Intent.ACTION_MAIN) && intent.getData() != null) {
|
if (intent != null && !intent.getAction().equals(Intent.ACTION_MAIN) && intent.getData() != null) {
|
||||||
Intent loadIntent = new Intent(EditFragment.LOAD_ACTION);
|
Intent loadIntent = new Intent(EditFragment.LOAD_ACTION);
|
||||||
|
@ -102,18 +102,19 @@ public class MainActivity extends AppCompatActivity
|
||||||
LocalBroadcastManager.getInstance(getApplicationContext())
|
LocalBroadcastManager.getInstance(getApplicationContext())
|
||||||
.sendBroadcast(loadIntent);
|
.sendBroadcast(loadIntent);
|
||||||
}
|
}
|
||||||
|
if (getResources().getConfiguration().orientation
|
||||||
|
== Configuration.ORIENTATION_LANDSCAPE) {
|
||||||
|
tabLayout.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkDirectories() {
|
@Override
|
||||||
File tmpDir = new File(getTempFilePath());
|
public void onConfigurationChanged(Configuration newConfig) {
|
||||||
if (!tmpDir.exists()) {
|
super.onConfigurationChanged(newConfig);
|
||||||
tmpDir.mkdir();
|
if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE)
|
||||||
}
|
tabLayout.setVisibility(View.GONE);
|
||||||
File outDir = new File(getFilePath());
|
else
|
||||||
if (!outDir.exists()) {
|
tabLayout.setVisibility(View.VISIBLE);
|
||||||
outDir.mkdir();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,16 +1,18 @@
|
||||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context="com.wbrawner.simplemarkdown.EditFragment">
|
tools:context="com.wbrawner.simplemarkdown.EditFragment">
|
||||||
<EditText
|
<EditText
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"
|
||||||
android:id="@+id/markdown_edit"
|
android:id="@+id/markdown_edit"
|
||||||
android:inputType="textMultiLine"
|
android:inputType="textMultiLine"
|
||||||
android:background="@null"
|
android:background="@null"
|
||||||
|
android:imeOptions="flagNoExtractUi"
|
||||||
|
android:gravity="top"
|
||||||
android:padding="8dp"
|
android:padding="8dp"
|
||||||
android:hint="@string/markdown_here"
|
android:hint="@string/markdown_here"
|
||||||
android:scrollHorizontally="false" />
|
android:scrollHorizontally="false" />
|
||||||
|
|
||||||
</ScrollView>
|
</LinearLayout>
|
||||||
|
|
Loading…
Reference in a new issue