Keep screen ON on other activities.
This commit is contained in:
parent
c25fb43434
commit
aaffa44e7f
|
|
@ -19,8 +19,6 @@ import java.util.Collections;
|
|||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import fr.chteufleur.mytrackingdog.R;
|
||||
|
||||
public class FilePicker extends ListActivity {
|
||||
|
||||
public final static String EXTRA_FILE_PATH = "file_path";
|
||||
|
|
@ -40,15 +38,17 @@ public class FilePicker extends ListActivity {
|
|||
|
||||
LayoutInflater inflator = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
|
||||
View emptyView = inflator.inflate(R.layout.empty_view, null);
|
||||
((ViewGroup) getListView().getParent()).addView(emptyView);
|
||||
getListView().setEmptyView(emptyView);
|
||||
if (inflator != null) {
|
||||
View emptyView = inflator.inflate(R.layout.empty_view, null);
|
||||
((ViewGroup) getListView().getParent()).addView(emptyView);
|
||||
getListView().setEmptyView(emptyView);
|
||||
}
|
||||
|
||||
// Set initial directory
|
||||
Directory = new File(DEFAULT_INITIAL_DIRECTORY);
|
||||
|
||||
// Initialize the ArrayList
|
||||
Files = new ArrayList<File>();
|
||||
Files = new ArrayList<>();
|
||||
|
||||
// Set the ListAdapter
|
||||
Adapter = new FilePickerListAdapter(this, Files);
|
||||
|
|
@ -123,7 +123,7 @@ public class FilePicker extends ListActivity {
|
|||
private class FilePickerListAdapter extends ArrayAdapter<File> {
|
||||
private List<File> mObjects;
|
||||
|
||||
public FilePickerListAdapter(Context context, List<File> objects) {
|
||||
private FilePickerListAdapter(Context context, List<File> objects) {
|
||||
super(context, R.layout.list_item, android.R.id.text1, objects);
|
||||
mObjects = objects;
|
||||
}
|
||||
|
|
@ -133,24 +133,27 @@ public class FilePicker extends ListActivity {
|
|||
View row = null;
|
||||
|
||||
if (convertView == null) {
|
||||
LayoutInflater inflater = (LayoutInflater)
|
||||
getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
row = inflater.inflate(R.layout.list_item, parent, false);
|
||||
LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
if (inflater != null) {
|
||||
row = inflater.inflate(R.layout.list_item, parent, false);
|
||||
}
|
||||
} else {
|
||||
row = convertView;
|
||||
}
|
||||
|
||||
File object = mObjects.get(position);
|
||||
|
||||
ImageView imageView = row.findViewById(R.id.file_picker_image);
|
||||
TextView textView = row.findViewById(R.id.file_picker_text);
|
||||
textView.setSingleLine(true);
|
||||
textView.setText(object.getName());
|
||||
if (row != null) {
|
||||
ImageView imageView = row.findViewById(R.id.file_picker_image);
|
||||
TextView textView = row.findViewById(R.id.file_picker_text);
|
||||
textView.setSingleLine(true);
|
||||
textView.setText(object.getName());
|
||||
|
||||
if (object.isFile()) {
|
||||
imageView.setImageResource(R.drawable.ic_file);
|
||||
} else {
|
||||
imageView.setImageResource(R.drawable.ic_folder);
|
||||
if (object.isFile()) {
|
||||
imageView.setImageResource(R.drawable.ic_file);
|
||||
} else {
|
||||
imageView.setImageResource(R.drawable.ic_folder);
|
||||
}
|
||||
}
|
||||
|
||||
return row;
|
||||
|
|
@ -184,7 +187,7 @@ public class FilePicker extends ListActivity {
|
|||
|
||||
private String[] Extensions;
|
||||
|
||||
public ExtensionFilenameFilter(String[] extensions) {
|
||||
private ExtensionFilenameFilter(String[] extensions) {
|
||||
super();
|
||||
Extensions = extensions;
|
||||
}
|
||||
|
|
@ -197,8 +200,8 @@ public class FilePicker extends ListActivity {
|
|||
}
|
||||
|
||||
if (Extensions != null && Extensions.length > 0) {
|
||||
for (int i = 0; i < Extensions.length; i++) {
|
||||
if (filename.endsWith(Extensions[i])) {
|
||||
for (String ext: Extensions) {
|
||||
if (filename.endsWith(ext)) {
|
||||
// The filename ends with the extension
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ import android.content.res.Resources;
|
|||
import android.graphics.Bitmap;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
|
|
@ -26,6 +28,9 @@ public class QRCodeGeneratorActivity extends Activity {
|
|||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.qr_code_generator);
|
||||
|
||||
// Keep screen ON
|
||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
|
||||
imageView = findViewById(R.id.qr_code_image);
|
||||
while (generating) {
|
||||
try {
|
||||
|
|
@ -36,6 +41,12 @@ public class QRCodeGeneratorActivity extends Activity {
|
|||
if (image != null) {
|
||||
imageView.setImageBitmap(image);
|
||||
}
|
||||
imageView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
onBackPressed();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void textToImageEncode(String value, Resources resources) throws WriterException {
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import android.content.pm.PackageManager;
|
|||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.RequiresApi;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import com.google.zxing.Result;
|
||||
|
||||
|
|
@ -37,6 +38,10 @@ public class QRCodeReaderActivity extends Activity implements ZXingScannerView.R
|
|||
checkPermissions();
|
||||
}
|
||||
setContentView(R.layout.qr_code_reader);
|
||||
|
||||
// Keep screen ON
|
||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
|
||||
mScannerView = new ZXingScannerView(this);
|
||||
setContentView(mScannerView);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@
|
|||
|
||||
<ImageView
|
||||
android:id="@+id/qr_code_image"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="20dp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
|
|
|||
Loading…
Reference in New Issue